<div class="form-group mb0">
  <label class="col-sm-2 control-label">
    {{ 'course.marketing_setup.rule.expiry_date'|trans }}
    <a class="es-icon es-icon-help course-mangae-info__help text-normal" data-trigger="hover" data-toggle="popover"
       data-container="body" data-placement="top"
       data-content="<ul class='pl10 list-unstyled'>
      <li class='mb10'>{{ 'course.teaching_plan.expiry_date.anytime'|trans|raw }}</li>
      <li class='mb10'>{{ 'course.teaching_plan.expiry_date.real_time'|trans|raw }}</li>
      <li>{{ 'course.teaching_plan.expiry_date.overdue_tips'|trans }}</li>
    </ul>">
    </a>
  </label>
  <div class="col-sm-10 cd-radio-group mbm">
    {% set exercisePublished = exercise.status|default('draft') == 'published' %}
    {% set exerciseClosed = exercise.status|default('draft') == 'closed' %}
    {{ cd_radios('expiryMode',
      { 'days': 'course.teaching_plan.expiry_date.anywhere_mode'|trans, 'date': 'course.teaching_plan.expiry_date.date_mode'|trans,'forever':'course.teaching_plan.expiry_date.forever_mode'|trans },
      exercise.expiryMode|default('forever'), exercisePublished or exerciseClosed ? 'disabled' : '') }}

    {% if exercise.status|default('draft') != 'draft' %}
      <input type="hidden" name="expiryMode" value="{{ exercise.expiryMode|default('forever') }}">
    {% endif %}
    {#随到随学#}
    <div class="course-manage-expiry {% if exercise.expiryMode|default('forever') in ['date', 'forever'] %}hidden{% endif %}"
         id="expiry-days">
      <span class="caret"></span>
      {{ cd_radios('deadlineType',
        { 'end_date': 'course.teaching_plan.expiry_date.end_date_mode'|trans, 'days': 'course.teaching_plan.expiry_date.days_mode'|trans},
        exercise.deadlineType|default('days'),  exercisePublished or exerciseClosed ? 'disabled' : '') }}

      {% if exercisePublished or exerciseClosed %}
        <input type="hidden" name="deadlineType" value="{{ exercise.deadlineType|default('days') }}">
      {% endif %}

      <div class="cd-mt16 {% if exercise.deadlineType|default('days') != 'end_date' %}hidden{% endif %}"
           id="deadlineType-date">
        <input
          autocomplete="off" class="form-control course-mangae-info__input js-expiry-input cd-mr8" id="deadline"
          name="deadline"
          value="{% if exercise.expiryEndDate|default(0) %}{{ exercise.expiryEndDate|default(0) }}{% endif %}" {% if exercisePublished %} disabled {% endif %}>{{ 'course.marketing_setup.rule.expiry_date_tips'|trans }}
        {% if exercise.deadlineType|default('days') == 'end_date' and exercisePublished %}
          <input type="hidden" name="deadline" value="{{ exercise.expiryEndDate|default(0) }}">
        {% endif %}
      </div>
      <div class="cd-mt16 {% if exercise.deadlineType|default('days') != 'days' %}hidden{% endif %}"
           id="deadlineType-days">
        <input
          class="form-control course-mangae-info__input js-expiry-input cd-mr8" type="text" id="expiryDays"
          name="expiryDays"
          value="{% if exercise.expiryDays|default(1) %}{{ exercise.expiryDays|default(1) }}{% endif %}" {% if exercisePublished%}disabled {% endif %}>
        {{ 'course.marketing_setup.rule.expiry_date.publish_tips'|trans }}
        {% if exercise.deadlineType|default('days') == 'days' and exercisePublished %}
          <input type="hidden" name="expiryDays" value="{{ exercise.expiryDays|default(1) }}">
        {% endif %}
      </div>
    </div>
    {#固定周期#}
    <div class="course-manage-expiry {% if exercise.expiryMode|default('forever') in ['days', 'forever'] %}hidden{% endif %}"
         id="expiry-date">
      <span class="caret"></span>
      <div class="course-manage-expiry__circle">
        {{ 'course.plan_task.start_time'|trans }}
        <input
          class="form-control cd-ml16 cd-mr32 course-mangae-info__input js-expiry-input" id="expiryStartDate"
          type="text" name="expiryStartDate"
          value="{% if exercise.expiryStartDate|default(0) == 0 %}{{ 'now'|date('Y-m-d') }}{% else %}{{ exercise.expiryStartDate|default('now'|date('Y-m-d')) }}{% endif %}" {% if exercisePublished %} disabled {% endif %}>{{ 'course.plan_task.end_time'|trans }}
        <input
          class="form-control cd-ml16 course-mangae-info__input js-expiry-input" type="text" id="expiryEndDate"
          name="expiryEndDate"
          value="{% if exercise.expiryEndDate|default(0) != 0 %}{{ exercise.expiryEndDate|default(0) }}{% endif %}"
          {% if exercisePublished %}disabled {% endif %} >
        {% if exercise.expiryMode|default('days') == 'date' and exercisePublished %}
          <input type="hidden" name="expiryStartDate" value="{{ exercise.expiryStartDate|default('now'|date('Y-m-d')) }}">
          <input type="hidden" name="expiryEndDate" value="{{ exercise.expiryEndDate|default(0) }}">
        {% endif %}
      </div>
    </div>
    <div
      class="course-mangae-info__tip js-expiry-tip {% if exercise.expiryMode|default('forever') == 'forever' %} ml0 {% endif %}">{{ 'item_bank_exercise.marketing_setup.rule.expiry_date.first_publish_tips'|trans }}</div>
  </div>
</div>
